package com.example.xpagedemoproject.fragment;

import android.content.Intent;
import android.os.Bundle;

import com.example.xpagedemoproject1.R;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.base.XPageSimpleListFragment;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xutil.tip.ToastUtils;

import java.util.List;

@Page(name = "切换动画")
public class AnimationFragment extends XPageSimpleListFragment {
    @Override
    protected List<String> initSimpleData(List<String> lists) {
        lists.add("没有动画");
        lists.add("由下到上动画");
        lists.add("从左到右动画");
        lists.add("渐变");
        lists.add("放大");
        lists.add("自定义动画");
        return lists;
    }

    @Override
    protected void onItemClick(int position) {
        Bundle bundle = new Bundle();
        bundle.putBoolean(DataReceiveFragment.KEY_IS_NEED_BACK,true);
        switch (position) {
            case 0:
                openPage(TestFragment.PAGE_NAME,bundle, CoreAnim.none);
                break;
            case 1:
                openPage(TestFragment.PAGE_NAME,bundle,CoreAnim.present);
                break;
            case 2:
                openPage(TestFragment.PAGE_NAME,bundle,CoreAnim.slide);
                break;
            case 3:
                openPage(TestFragment.PAGE_NAME,bundle,CoreAnim.fade);
                break;
            case 4:
                openPage(TestFragment.PAGE_NAME,bundle,CoreAnim.zoom);
                break;
            case 5:
                openPage(TestFragment.PAGE_NAME,bundle,new int[]{
                        R.anim.custom_open_enter,
                        R.anim.custom_open_exit,
                        R.anim.custom_open_enter,
                        R.anim.custom_open_exit
                });
                break;
            default:
                break;
        }

    }

    @Override
    public void onFragmentResult(int requestCode, int resultCode, Intent data) {
        super.onFragmentResult(requestCode, resultCode, data);
        if (data != null) {
            Bundle bundle = data.getExtras();
            if (bundle.getString(DataReceiveFragment.KEY_BACK_DATA) != null) {
                ToastUtils.toast("返回数据是：" + bundle.getString(DataReceiveFragment.KEY_BACK_DATA));
            }

        }
    }
}
